<?php
require_once ("src/db/connectdatabase.php");

function getInfoDoiTuong($id) {
	$con = new ConnectDB();
	
	$sql = "Select i.keyipro, i.prkey, p.prname, i.bankid, b.bankname, b.banklogo, i.dac_tinh_loan, i.object_dk_loan, i.thu_tuc_loan FROM loan_for_intro_product as i, banks as b, loan_products_rate_for as p WHERE i.prkey=p.prkey AND i.bankid=b.bankid AND i.keyipro='".$id."' AND i.isavalible='1' ORDER BY i.datecreate DESC";
	return $con -> getvalueString($sql);
}

function getInfoDoiTuongLienQuan($idtype, $idcurrent) {
	$con = new ConnectDB();
	
	$sql = "Select i.keyipro, i.prkey, p.prname, i.bankid, b.bankname, b.banklogo, i.dac_tinh_loan, i.object_dk_loan, i.thu_tuc_loan FROM loan_for_intro_product as i, banks as b, loan_products_rate_for as p WHERE i.prkey=p.prkey AND i.bankid=b.bankid AND i.prkey LIKE '%".$idtype."%' AND i.keyipro <>'".$idcurrent."' ORDER BY i.datecreate DESC LIMIT 0,5";
	return $con -> getvalueString($sql);
}

function int_to_date($int)
{
    $time  = date("d/m/Y", $int);
    return $time;
}

if(isset($_GET['id'])) {
	$id = $_GET['id'];
	$arrnew = getInfoDoiTuong($id);
	if(count($arrnew) > 0) {
?>
<style>
div.product_tab_title {
    height: 35px;
    border-radius: 5px 5px 0px 0px;
    line-height: 35px;
    padding: 0px 10px 0px 20px;
    overflow: hidden;
	background: #8EAE49;
}

SPAN.product_tab_title {
    color: rgb(255, 255, 255);
    font-weight: bold;
    text-transform: uppercase;
}

DIV.product_detail_related {
    border-right: 1px solid #8EAE49;
    border-width: medium 1px 1px;
    border-style: none solid solid;
    border-color: #8EAE49 #8EAE49;
    border-top-colors: none;
    border-right-colors: none;
    border-bottom-colors: none;
    border-left-colors: none;
    border-image: none;
    border-radius: 0px 0px 5px 5px;
    padding: 10px;
    background-color: rgb(255, 255, 255);
    position: relative;
}

DIV.product_content_part {
    padding-bottom: 15px;
	
    padding-left: 10px;
}

P.product_detail_title_tab {
    margin: 0px;
    padding-bottom: 10px;
    color: #8EAE49;
    font-size: 13px;
    font-weight: bold;
}
</style>
<div class="intrl_txt" style="margin: auto;">
    <div style="float: left; clear: right;">
        <div class="text12" style="margin:auto; width:970px; height:11px; color:#0a8bd9;"><u><a href="<?php echo($host) ?>" class="text12" style="color:#0080d6;">Trang chủ</a></u> &gt; Thông tin chương trình cho vay</div>
        <div style="width:663px; max-width:663px; height: auto; margin-top:0px; float:left; clear:right;">
            <div style="height: auto; margin-top:15px; clear:right;">
                <div class="product_tab_title"><span class="product_tab_title"><?php echo($arrnew[0][4]) ?></span></div>
                <div class="product_detail_related">
                    <div class="product_content_part">
                        <p class="product_detail_title_tab">Đặc Tính</p>
                        <span style="font-size: 9pt;"><?php echo($arrnew[0][6]) ?></span>
                    </div>
                    <div class="product_content_part">
                        <p class="product_detail_title_tab">Đối Tượng - Điều Kiện Vay</p>
                        <span style="font-size: 9pt;"><?php echo($arrnew[0][7]) ?></span>
                    </div>
                    <div class="product_content_part">
                        <p class="product_detail_title_tab">Thủ Tục Vay Vốn</p>
                        <span style="font-size: 9pt;"><?php echo($arrnew[0][8]) ?></span>
                    </div>
                </div>
            </div>
            <div class="clear" style="height: 30px;"></div>
            <div>
            	<h1 style="font-size: 15px; text-transform:uppercase;">Sản phẩm vay tiêu dùng liên quan dành cho <?php echo($arrnew[0][2]) ?></h1>
                <?php 
				$arrnewcungchuyenmuc = getInfoDoiTuongLienQuan($arrnew[0][1], $id);
				foreach($arrnewcungchuyenmuc as $entry) {
					$strbanknameurl2 = $entry[4];
					$strbanknameurl2 = rewriteTextUrl(stripUnicode($strbanknameurl2));
				?>
                <p><strong><a class="link-click-xemthem-class" href="<?php echo($host) ?>doi-tuong-cho-vay/<?php echo($entry[0]) ?>/<?php echo ($strbanknameurl2); ?>.html"><?php echo($entry[4]) ?></a></strong></p>
                <?php } ?>
            </div>
        </div>
        
        <div style="float: right; clear: right; background-image: url(<?php echo($host) ?>images/gray_bg.gif); width: 275px; height: auto; margin-top: 10px;">
            <?php include("formsendapplyloan.php"); ?>
        </div>
        <div class="clear"></div>
	</div>
</div>
<style>
.link-click-xemthem:hover {
	color: #06F;
	text-decoration:none;
}
</style>
<?php
	}
}
?>